package com.hsw.habit.controller;

import com.alibaba.fastjson.JSONObject;
import com.hsw.habit.frame.annotation.CurrentUser;
import com.hsw.habit.frame.annotation.LoginRequired;
import com.hsw.habit.frame.annotation.UserId;
import com.hsw.habit.model.JsonData;
import com.hsw.habit.model.TaskGroups;
import com.hsw.habit.model.User;
import com.hsw.habit.service.GroupService;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@RestController
@RequestMapping("/index")
public class IndexController {

    @Resource
    GroupService groupService;

    @LoginRequired
    @RequestMapping("/groupItem")
    public JsonData getItem(int id) {
        TaskGroups taskGroups = groupService.selectGroupById(id);
        if (null != taskGroups) {
            return JsonData.success(taskGroups);
        } else {
            return JsonData.error(4001,"没有找到");
        }
    }

    @LoginRequired
    @RequestMapping("/insert")
    public JsonData insertItem(@UserId int userId) {
         return JsonData.success(userId);

//        groupService.insertGroup(taskGroups);
    }
}
